package com.ruoyi.repairCar.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.repairCar.domain.Store;
import com.ruoyi.repairCar.service.IStoreService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 车辆维修Controller
 *
 * @author djt
 * @date 2025-03-17
 */
@RestController
@RequestMapping("/repairCar")
public class StoreController extends BaseController
{
    @Autowired
    private IStoreService storeService;

    /**
     * 查询店铺信息以及服务列表
     */
    @GetMapping("/Storelist/{storeId}")
    public TableDataInfo list(@PathVariable("storeId") Long storeId)
    {
        startPage();
        List<Store> list = storeService.selectStoreList(storeId);
        return getDataTable(list);
    }
    /**
     * 查询所有店铺信息以及服务列表
     */
    @GetMapping("/AllStorelist")
    public TableDataInfo list(){
        startPage();
        List<Store> list = storeService.selectStoreWithServiceItemsAll();
        return getDataTable(list);
    }


    /**
     * 获取订单以及服务评价
     */
    @GetMapping(value = "/orderList/{storeId}")
    public TableDataInfo getInfo(@PathVariable("storeId") Long storeId)
    {
        startPage();
        List<Store> list = storeService.selectOrdersByStoreId(storeId);
        return getDataTable(list);
    }

    /**
     * 新增车辆维修
     */
    @Log(title = "车辆维修", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Store store)
    {
        return toAjax(storeService.insertStore(store));
    }

    /**
     * 修改车辆维修
     */
    @Log(title = "车辆维修", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Store store)
    {
        return toAjax(storeService.updateStore(store));
    }

    /**
     * 删除车辆维修
     */
    @Log(title = "车辆维修", businessType = BusinessType.DELETE)
    @DeleteMapping("/{storeIds}")
    public AjaxResult remove(@PathVariable Long[] storeIds)
    {
        return toAjax(storeService.deleteStoreByStoreIds(storeIds));
    }
}